<title>订单分析数据</title>
<link rel="stylesheet" href="/static/public/vendor/select2/select2.css">

<script src="/static/public/vendor/select2/select2.min.js" data-name="select2"></script>
<script src="/static/public/vendor/select2/i18n/zh-CN.min.js" data-deps="select2"></script>
<div class="page-content">
    <div class="collapse in" id="collapseFilter" aria-expanded="true">
        <div class="panel">
            <div class="panel-body">

                <form class="form-inline" id="projectForm">
                    <div class="form-group">
                        <select id="batchId" onchange="change()" class="form-control" name="url" data-plugin="select2" style="width: 200px">
                            <option value="">项目名称</option>
                            #foreach( $prj in $prjList )
                            <option value="${prj.id}">${prj.name}</option>
                            #end
                        </select>
                    </div>
                    <div class="form-group">
                        <span class="btn btn-success" onclick="query()"><i class="icon fa-search"></i> 查找</span>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="panel">
        <div class="panel-body">
            <table class="table table-bordered table-hover dataTable table-striped width-full text-nowrap"
                   id="dataTableExample">
                <thead>
                <tr>
                    <th>登录账号</th>
                    <th>用户名</th>
                    <th>公司名称</th>
                    <th>申请日期</th>
                    <th>审核</th>
                </tr>
                </thead>
            </table>
        </div>
    </div>
</div>

<script src="/static/public/vendor/bootstrap-select/bootstrap-select.min.js"></script>
<script type="text/javascript">
    var $table = null;

    function query() {
        $table.ajax.reload();
    }
    function reloadData() {
        $table.ajax.reload();
    }
    function change() {
        $table.ajax.reload();
    }
    function editUser(id){
        $.ajax({
            type: "POST",
            url: "#springUrl('/perm/user/examineA/')" + id,
            datatype: "text",
            success: function (data) {
                if(data == 'true'){
                    change();
                }
            }
        });
    }
    $(function () {
        $table = $('#dataTableExample').DataTable($.po('dataTable', {
            "processing": true,
            "serverSide": true,
            "ordering": false,
            "columns": [
                {"data": "loginName"},
                {"data": "name"},
                {"data": "company"},
                {"data": "crTime"},
                {"data": "id"},
            ],
            "columnDefs": [{
                "render": function (data, type, row) {
                    return Date.format(new Date(data), "yyyy-MM-dd hh:mm:ss");
                },
                "targets": 3
            },
                {"render": function (data, type, row) {
                    if(data==null){
                        return "没上传数据";
                    }else {
                        var id = data;
                        return '<a class="btn btn-xs btn-warning" onclick="editUser(' + "'" + id + "'" + ')"><i class="fa fa-pencil"></i>通过审核</a> '
                    }
                }, "targets": 4}
                ],
            "dom": '<"dt-dom-toolbar">rt<"bottom"pi>',
            "fnServerData": function (sSource, aoData, fnCallback) {
                var params = [
                    {name: "size", value: aoData[4].value}, {
                        name: "current", value: aoData[3].value / aoData[4].value + 1
                    }];
                $.ajax({
                    "dataType": 'json',
                    "type": "post",
                    "data": params,
                    "url": "/perm/user/getData",
                    "success": fnCallback
                });
            }
        }));


    })
</script>